<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            到厂收货
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">业务类型</div>
                    <div class="aui-list-item-input">
                        <select id="businessType" onchange="onChangeInBusiness()">
                  </select>
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">子业务类型</div>
                    <div class="aui-list-item-input">
                        <select id="subBusinessType">
                  </select>
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">要货日期</div>
                    <div class="aui-list-item-input" onclick="timePicker();">
                        <input type="text" placeholder="选择日期" class="aui-input" id="needDate">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">物料号</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="请 录入/扫描物料号" id="mrlCode" onclick="getIdSelector();">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">物料名</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="mrlName" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item" style="display:none">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">批次号</div>
                    <div class="aui-list-item-input">
                        <input type="text" id="lotCode" value="000000">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">要货数量</div>
                    <div class="aui-list-item-input">
                        <input type="number" id="needQty" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">已到货数量</div>
                    <div class="aui-list-item-input">
                        <input type="number" id="dhQty" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">到货数量</div>
                    <div class="aui-list-item-input">
                        <input type="number" id="qty" onclick="getIdSelector();">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">仓库</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="选择/扫描 仓库" id="workCenterCode" value="" onclick="getIdSelector();" />
                    </div>
                    <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="goSelectWorkCenter()"></i>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">库位</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="选择/扫描 库位" id="workCellCode" value="" onclick="getIdSelector();" />
                    </div>
                    <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="goSelectWorkCell()"></i>
                </div>
            </li>
        </ul>
        <div style="width:100%;margin-top:5px;"></div>
        <div class="aui-btn aui-btn-info" style="margin-left:5%;width:40%" onclick="doSearch()">查询</div>
        <div class="aui-btn aui-btn-info " style="margin-left:5%;width:40%" onclick="save()">保存</div>
        <div style="background-color:white; height: 270px;width: 100%;margin-top:3%;border:solid 1px #D3D3D3;display:none" id="tableDiv">
            <table class="table" style='width:100%; font-size:14px;' id="table">
                <tbody>
                    <tr>
                        <td style="width:23%;text-align:right;">业&nbsp&nbsp务&nbsp类&nbsp型:</td>
                        <td id="businessTypeT"></td>
                    </tr>
                    <tr>
                        <td style="width:23%;text-align:right;">子业务类型:</td>
                        <td id="subBusinessTypeT"></td>
                    </tr>
                    <tr>
                        <td style="width:23%;text-align:right;">仓&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp库:</td>
                        <td id="workCenterNameT"></td>
                    </tr>
                    <tr>
                        <td style="width:23%;text-align:right;">库&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp位:</td>
                        <td id="workCellNameT"></td>
                    </tr>
                    <tr>
                        <td style="width:23%;text-align:right;">物&nbsp&nbsp&nbsp&nbsp料&nbsp&nbsp&nbsp&nbsp号:</td>
                        <td id="mrlCodeT"></td>
                    </tr>
                    <!-- <tr>
                        <td style="width:23%;text-align:right;">批&nbsp&nbsp&nbsp&nbsp次&nbsp&nbsp&nbsp&nbsp号:</td>
                        <td id="lotCodeT"></td>
                    </tr> -->
                    <tr>
                        <td style="width:23%;text-align:right;">入&nbsp&nbsp库&nbsp数&nbsp量:</td>
                        <td id="qtyT"></td>
                    </tr>
                    <tr>
                        <td style="width:23%;text-align:right;">操&nbsp&nbsp&nbsp&nbsp作&nbsp&nbsp&nbsp&nbsp者:</td>
                        <td id="createIdT"></td>
                    </tr>
                    <tr>
                        <td style="width:23%;text-align:right;">操&nbsp&nbsp作&nbsp时&nbsp间:</td>
                        <td id="createDateT"></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <footer class="aui-bar aui-bar-tab" id="footer">
        <div class="aui-bar-tab-item" tapmode id="scan" onclick="doScan()">
            <i class="aui-iconfont aui-icon-scan aui-text-epblue" style="font-size: 1.8rem"></i>
        </div>
    </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";
    var workCenterGid = ""; //仓库GID
    var workCenterCode = ""; //仓库编码
    var workCenterName = ""; //仓库名称
    var workCellGid = ""; //库位GID
    var workCellCode = ""; //库位编码
    var workCellName = ""; //库位名称

    //初始化
    apiready = function() {

        $("#mrlCode").focus();
        idSelector = "mrlCode";

        //默认当前日期
        crateDate();

        //查询业务类型下拉框
        doSearchBusinessType();
    }

    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }

    //获取当前日期
    function crateDate() {
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        $("#needDate").val(year + "-" + month + "-" + day);
    }

    //时间选择器
    function timePicker() {
        api.openPicker({
            type: 'date',
            date: new Date(),
            title: '选择日期'
        }, function(ret, err) {
            if (ret) {
                var monthTemp = (ret.month < 10 ? '0' + ret.month : ret.month);
                var dayTemp = (ret.day < 10 ? '0' + ret.day : ret.day);
                var date = ret.year + "-" + monthTemp + "-" + dayTemp;
                $("#needDate").val(date);
            }
        });
    }

    //业务类型下拉框
    function doSearchBusinessType() {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getBusinessType";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                type: 'IN',
                un:un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var map = eval("(" + data + ")");
                var list = eval(map.list);
                var html = "<option value=''>--请选择--</option>";
                for (var i = 0; i < list.length; i++) {
                    html += "<option value='" + list[i].code + "'>" + list[i].name + "</option>";
                }
                $api.html($api.byId("businessType"), html);
            }
        });
    }

    //业务类型下拉框值改变
    function onChangeInBusiness() {
        var businessType = $("#businessType").val();
        //源仓库不为空，查询库位下拉框
        if (businessType != "" && businessType != null && businessType != undefined) {
            var un = localStorage.getItem('un');
            var serverUrl = localStorage.getItem('serverUrl');
            var url = serverUrl + "/app/getSubBusinessType";
            var data = {
                values: { ////以表单方式提交参数（JSON对象）
                    type: 'IN',
                    businessType: businessType,
                    un:un
                }
            };
            api.ajax({
                url: url,
                method: 'post',
                dataType: 'json',
                timeout: 300,
                returnAll: false,
                data: data
            }, function(ret, err) {
                if (ret) {
                    var data = JSON.stringify(ret);
                    var map = eval("(" + data + ")");
                    var list = eval(map.list);
                    var html = "<option value=''>--请选择--</option>";
                    for (var i = 0; i < list.length; i++) {
                        html += "<option value='" + list[i].sysid + "'>" + list[i].name + "</option>";
                    }
                    $api.html($api.byId("subBusinessType"), html);
                }
            });
        } else {
            $api.html($api.byId("subBusinessType"), "");
        }
    }

    //扫描
    function doScan() {
        var moduleScanner = api.require('moduleScanner');
        var params = {
            top: 150, //扫描窗口的上边距
            width: 250, //扫描窗口的宽
            height: 250, //扫描窗口的高
            useColor: false, //是否使用自己设定的颜色(startColor和endColor),
            //如果不使用设定的颜色就使用默认的那张网格图
            startColor: '#0F08C8FF', //渐变起始颜色
            endColor: '#7F08C8FF', //渐变结束颜色
            animTime: 2200, //扫描动画时间,单位为毫秒
        };
        moduleScanner.toScannerActivityForResult(params, function(ret, err) {
            //1：仓库
            if (idSelector == 'workCenterCode') {

                $("#workCenterCode").val(ret);
                //查询仓库
                getWorkCenter(ret, idSelector);

                //2:库位
            } else if (idSelector == 'workCellCode') {

                $("#workCellCode").val(ret);
                //查询库位
                getWorkCell(ret, idSelector);

                //扫描物料号
            } else if (idSelector == 'mrlCode') {

                $("#mrlCode").val(ret);
                //值改变查询日要货计划
                doSearch();
            }
        });
    }

    //查询
    function doSearch() {
        //要货日期
        var needDate = $("#needDate").val();
        //物料号
        var mrlCode = $("#mrlCode").val();

        //要货日期非空校验
        if (needDate == "" || needDate == null || needDate == undefined) {
            api.toast({
                msg: "请选择要货日期",
                duration: 3000
            });
            return;
        }

        //物料号非空校验
        if (mrlCode == "" || mrlCode == null || mrlCode == undefined) {
            api.toast({
                msg: "请 录入/扫描物料号",
                duration: 3000
            });
            return;
        }

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getMrlNeedPlanTjcl";
        var data = {
            values: {
                needDate: needDate,
                mrlCode: mrlCode,
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {

                    $("#mrlName").val(myobj.mrlName);
                    $("#needQty").val(myobj.needQty);
                    $("#dhQty").val(myobj.dhQty);
                    $("#qty").val(myobj.qty);

                } else {
                    // $("#mrlCode").val("");
                    $("#mrlName").val("");
                    $("#needQty").val("");
                    $("#dhQty").val("");
                    $("#qty").val("");
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //1：仓库扫描校验
    function getWorkCenter(code, inputId) {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getWorkCenter";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                workCenterCode: code,
                mrlCode: "",
                lotCode: "",
                qty: "",
                un:un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {
                    var list = eval(myobj.list);

                    if (list.length > 0) {
                        workCenterGid = list[0].workCenterGid;
                        workCenterCode = list[0].workCenterCode + ":" + list[0].workCenterName;
                        workCenterName = list[0].workCenterName;
                        document.getElementById(inputId).value = workCenterCode;
                        $("#workCellCode").focus();
                        idSelector = "workCellCode";
                    } else {
                        workCenterGid = "";
                        workCenterCode = "";
                        workCenterName = "";
                        document.getElementById(inputId).value = workCenterCode;

                        api.toast({
                            msg: "仓库编码【" + code + "】不存在!",
                            duration: 3000
                        });
                    }

                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    $("#workCenterCode").val("");
                    idSelector = "workCenterCode";
                    $("#workCenterCode").focus();
                }
            }
        });
    }

    //2：选中仓库
    function goSelectWorkCenter() {
        api.openWin({
            name: 'uwmSelectWorkCenter',
            url: 'uwmSelectWorkCenter.html',
            pageParam: {
                flag: "in",
                name: "tjclFactoryReceive",
                mrlCode: "",
                lotCode: "",
                qty: ""
            }
        });
    }

    //仓库选择后回调函数
    function setWorkCenter(id, code, name) {
        workCenterGid = id;
        workCenterCode = code;
        workCenterName = name;
        //$("#workCenterCode").attr("value",code+":"+name);
        document.getElementById('workCenterCode').value = code + ":" + name;
        $("#workCellCode").focus();
        idSelector = "workCellCode";
    }

    //3：PDA仓库自带扫描回车事件
    $("#workCenterCode").on('keypress', function(e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var sm = $(this).val();
        if (keycode == '13') {

            //仓库编码
            $("#workCenterCode").val(sm);
            //查询仓库编码是否存在
            getWorkCenter(sm, "workCenterCode");
        }
    });

    //5:库位扫描校验
    function getWorkCell(code, inputId) {
        var workCenterCodeR = $("#workCenterCode").val();

        //扫库位前先扫仓库
        if (inputId == "workCellCode") {
            if (workCenterGid == "" || workCenterGid == null || workCenterGid == undefined) {
                api.toast({
                    msg: "请先选择/扫描 仓库",
                    duration: 3000
                });
                $("#workCellCode").val("");
                workCellCode = "";
                workCellGid = "";
                workCellName = "";
                return;
            }

            if (workCenterCodeR == "" || workCenterCodeR == null || workCenterCodeR == undefined) {
                api.toast({
                    msg: "请先选择/扫描 仓库",
                    duration: 3000
                });
                $("#workCellCode").val("");
                workCellCode = "";
                workCellGid = "";
                workCellName = "";
                return;
            }
        }
        var un = localStorage.getItem("un");
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getWorkCell";
        var data = {
            values: {
                flag: "in_rk", //库内库间标识（out_kn库内  out_kj库间,in_rk入库出库）
                workCenterGid: workCenterGid, //仓库GID
                workCellCode: code, //库位编码
                relWorkCellGid: "", //调入库位
                tm: "",
                workCellFlag: "", //原库位调入库位flag
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);

                    if (list.length > 0) {

                        workCellGid = list[0].workCellGid;
                        workCellCode = list[0].workCellCode + ":" + list[0].workCellName;
                        workCellName = list[0].workCellName;
                        document.getElementById(inputId).value = workCellCode;
                    } else {
                        workCellGid = "";
                        workCellCode = "";
                        workCellName = "";
                        document.getElementById(inputId).value = workCellCode;

                        api.toast({
                            msg: "库位编码【" + code + "】不存在!",
                            duration: 3000
                        });
                    }

                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    $("#workCellCode").val("");
                    idSelector = "workCellCode";
                    $("#workCellCode").focus();
                }
            }
        });
    }

    //6：选择库位
    function goSelectWorkCell() {

        var workCenterCodeR = $("#workCenterCode").val();
        //仓库非空校验
        if (workCenterGid == "" || workCenterGid == null || workCenterGid == undefined) {
            api.toast({
                msg: "请先选择/扫描 仓库",
                duration: 3000
            });
            return;
        }

        //仓库非空校验
        if (workCenterCodeR == "" || workCenterCodeR == null || workCenterCodeR == undefined) {
            api.toast({
                msg: "请先选择/扫描 仓库",
                duration: 3000
            });
            return;
        }

        api.openWin({
            name: 'uwmSelectWorkCell',
            url: 'uwmSelectWorkCell.html',
            pageParam: {
                flag: "in_rk",
                name: "tjclFactoryReceive",
                tm: "",
                workCenterGid: workCenterGid,
                relWorkCellGid: "",
                workCellFlag: ""
            }
        });
    }

    //库位选择后回调函数
    function setWorkCell(id, code, name) {
        workCellGid = id;
        workCellCode = code;
        workCellName = name;
        document.getElementById('workCellCode').value = code + ":" + name;
    }

    //7；PDA自带扫描回车事件-库位
    $("#workCellCode").on('keypress', function(e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var sm = $(this).val();
        if (keycode == '13') {

            //仓库编码
            $("#workCellCode").val(sm);
            //校验库位是否存在
            getWorkCell(sm, "workCellCode");
        }
    });

    //保存按钮
    function save() {
        //业务类型
        var businessType = $("#businessType").val();
        //子业务类型
        var subBusinessType = $("#subBusinessType").val();
        //物料号
        var mrlCode = $("#mrlCode").val();
        //批次号
        var lotCode = $("#lotCode").val();
        //入库数量
        var qty = $("#qty").val();
        //仓库编码
        var workCenterCodeR = $("#workCenterCode").val();
        //仓库编码
        var workCellCodeR = $("#workCellCode").val();
        //要货数量
        var needQty = $("#needQty").val();
        //已到货数量
        var dhQty = $("#dhQty").val();
        //理论接收数量
        var overageQty = parseInt(needQty) - parseInt(dhQty);
        //要货日期
        var needDate = $("#needDate").val();

        //业务类型非空校验
        if (businessType == "" || businessType == null || businessType == undefined) {
            api.toast({
                msg: '请选择业务类型',
                duration: 3000
            });
            return;
        }

        //物料非空校验
        if (needDate == "" || needDate == null || needDate == undefined) {
            api.toast({
                msg: '请选择要货日期',
                duration: 3000
            });
            return;
        }

        //物料非空校验
        if (mrlCode == "" || mrlCode == null || mrlCode == undefined) {
            api.toast({
                msg: '请 录入/扫描物料号',
                duration: 3000
            });
            return;
        }

        //数量非空校验
        if (qty == "" || qty == null || qty == undefined) {
            api.toast({
                msg: '到货数量必须大于0',
                duration: 3000
            });
            return;
        }

        //数量非空校验
        if (parseFloat(qty) <= 0) {
            api.toast({
                msg: '到货数量必须大于0',
                duration: 3000
            });
            return;
        }

        //仓库非空校验
        if (workCenterCodeR == "" || workCenterCodeR == null || workCenterCodeR == undefined) {
            api.toast({
                msg: '请选择/扫描仓库',
                duration: 3000
            });
            return;
        }

        //仓库非空校验
        if (workCenterGid == "" || workCenterGid == null || workCenterGid == undefined) {
            api.toast({
                msg: '请选择/扫描仓库',
                duration: 3000
            });
            return;
        }

        //库位非空校验
        if (workCellCodeR == "" || workCellCodeR == null || workCellCodeR == undefined) {
            api.toast({
                msg: '请选择/扫描库位',
                duration: 3000
            });
            return;
        }

        //库位非空校验
        if (workCellGid == "" || workCellGid == null || workCellGid == undefined) {
            api.toast({
                msg: '请选择/扫描库位',
                duration: 3000
            });
            return;
        }


        //接收数量<=理论接收数，直接保存
        if (overageQty >= parseInt(qty)) {

            saveIn(workCenterGid, workCellGid, mrlCode, lotCode, qty, needDate);

            //接收数量>理论接收数，弹框确认
        } else {

            api.confirm({
                title: '确认入库(理论收货数：' + overageQty + ')',
                msg: "仓库：" + workCenterCodeR + "\n库位：" + workCellCodeR + "\n物料号：" + mrlCode + "\n入库数量：" + qty,
                buttons: ['确定', '取消']
            }, function(ret, err) {
                var index = ret.buttonIndex;
                if (index == 1) {

                    //入库保存
                    saveIn(workCenterGid, workCellGid, mrlCode, lotCode, qty, needDate);
                }
            });
        }
    }

    //保存
    function saveIn(workCenterGid, workCellGid, mrlCode, lotCode, qty, needDate) {
        api.showProgress({
            title: '保存中...',
        });
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/uwmInOfStocTjclkSave";
        var data = {
            values: {
                businessType: businessType, //业务类型
                subBusinessType: subBusinessType, // 子业务类型
                workCenterGid: workCenterGid, //仓库id
                workCellGid: workCellGid, //库位id
                mrlCode: mrlCode, //物料号
                lotCode: lotCode, //批次号
                qty: qty, //转移数量
                needDate: needDate, //要货日期
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {

                    api.hideProgress();
                    api.toast({
                        msg: "保存成功",
                        duration: 3000
                    });

                    //清空表单
                    $("#mrlCode").val("");
                    $("#mrlName").val("");
                    $("#needQty").val("");
                    $("#dhQty").val("");
                    $("#qty").val("");

                    var map = myobj.data;
                    for (var key in map) {
                        $("#" + key).html(map[key]);
                    }
                    $("#tableDiv").css('display', 'block');

                    idSelector = "mrlCode";
                } else if (myobj.code == '1') {
                    api.hideProgress();
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                api.hideProgress();
            }
        });
    }

    //物料号监听回车事件
    $("#mrlCode").on('keypress', function(e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var tm = $(this).val();
        if (keycode == '13') {

            $("#mrlCode").val(tm);

            //查询要货信息
            doSearch();
        }
    });

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>
